Defer BLS signature decompression until verification - #427
Draft
sausagee wants to merge 1 commit into
Draft
Conversation
Keep AggregateSignature and SignatureWithStatus in compressed 96-byte wire form so LedgerInfo commit-vote matching is not blocked by G2 point recovery. Recover the group element only on verification and aggregation paths. BCS/JSON encoding stays identical to bls12381::Signature. This is a clean-room rewrite of the deferred-decompression invariant for m1; it does not cherry-pick or port aptos-labs/aptos-core. Co-authored-by: Young Yang Liauw <sausagee@users.noreply.github.com>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Clean-room rewrite on
m1(not a cherry-pick, patch, or mechanical port fromaptos-labs/aptos-core). Upstream intent was read only to identify the bug and the invariant that must hold (aptos-labs/aptos-core#20089).types/src/lazy_bls.rsdoes not exist on this branch; this tree uses a different type (WireBlsSignatureintypes/src/wire_bls.rs) with a different structure, names, comments, and tests.Bug:
AggregateSignatureandSignatureWithStatusdeserialized throughbls12381::Signature, which recovers a G2 point (field square-root) inside serde/TryFrom. A well-formed-length but invalid payload then failed to decode, so a later full-LedgerInfocommit-vote match could never inspect the ledger fields.Invariant:
Signatureserde newtype). It does not recover a group element.LedgerInfo/ commit info only and must succeed without decompression.bls12381::Signature. Consensus-facing maps stayBTreeMap. Nounsafe.How Has This Been Tested?
cargo test -p aptos-types— 221 passed (includes new wire-compat tests, junk-payload decode, LedgerInfo match without decompression, plus existingvalidator_verifier/ledger_info/ aggregator tests).wire_bls, junk payload, signature status/aggregator, verifier): 21 passed.cargo test -p aptos-consensus-types— 19 passed.cargo test -p aptos-safety-rules— 13 passed.cargo test -p aptos-consensustargeted:pending_votes(3),pending_order_votes(2),buffer_item(2),signing_phase(1) — all passed.Aikido SAST was attempted on the new/modified files. The Aikido MCP is not authenticated in this environment (
aikido_loginrequires a browser callback to localhost), so the scan could not complete here.Key Areas to Review
types/src/wire_bls.rs— length-only decode; explicitrecover_group_element.AggregateSignature/SignatureWithStatus— store compressed bytes; verify paths recover after structural checks.SignatureAggregator::try_aggregate— skips unrecoverable points; voting power is still checked on the stored voter set;verify_multi_signaturesthen checks the recovered bitmask.Type of Change
Which Components or Systems Does This Change Impact?
aptos-typesconsensus signature typesChecklist
RUST_SECURE_CODING.mdfollowed: nounsafe,BTreeMapfor consensus maps,Resulton recoverNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.